import {Component, OnInit, Input, Output, EventEmitter} from '@angular/core'

@Component({
  selector: 'app-child',
  templateUrl: './child.component.html',
  styleUrls: ['./child.component.scss']
})
export class ChildComponent implements OnInit {
  public childMsg: string = '我是Child的msg'
  @Input() msg: string
  @Input() run: any
  @Input() home: any

  @Output() ee = new EventEmitter()

  constructor() {
  }

  ngOnInit(): void {

  }

  execRun() {
    this.run()
  }

  execRun2() {
    console.log(this.home.msg)
    this.home.run()
  }

  childRun() {
    alert('child组件的childRun')
  }

  sendDataToParent() {
    console.log('sendDataToParent')
    this.ee.emit({
      name: 'jack', age: 23
    })
  }

}
